﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
using EnvDTE80;

namespace SinacorRules
{
    public sealed class Rule_BaseResourceAccess : BaseAddIn.Rules.BaseRuleAddIn
    {
        #region Campos

        private Type _tipoBaseResourceAccess;

        #endregion

        #region Construtor

        public Rule_BaseResourceAccess() :
            base("BaseResourceAccess", "SinacorRules.SinacorRules", typeof(Rule_BaseResourceAccess).Assembly)
        {
            _tipoBaseResourceAccess = typeof(Sinacor.Infra.Service.Data.BaseResourceAccess);
        }

        #endregion

        #region Protected Override Methods

        protected sealed override void Check(CodeClass2 classe)
        {
            if (classe.Namespace.Name.Contains(".ResourceAccess"))
            {
                if (!Common.Rotinas.CheckClassInheritance(classe, _tipoBaseResourceAccess))
                {
                    GeraProblemaAddIn(classe.StartPoint.Parent.Parent.FullName,
                                      classe.StartPoint.Line,
                                      classe.StartPoint.DisplayColumn,
                                      "BaseResourceAccessResolution",
                                      classe.Name,
                                      classe.Namespace.Name);
                }
            }
        }

        #endregion
    }
}